<%@ page pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>进销存管理系统-新增商品</title>
<link rel="stylesheet" href="${ctx}/bootstrap3/css/bootstrap.min.css">
<link rel="stylesheet" href="${ctx}/css/my.css">
<link href="${ctx}/My97DatePicker/skin/WdatePicker.css" rel="stylesheet">
<script  type="text/javascript" src="${ctx}/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
	<!-- 导航条 -->
	<jsp:include page="/mng/nav.jsp"/>
	<!-- /导航条 -->
	
	<!-- 主容器 -->
	<div class="container" style="margin-top: 76px">
	  <div class="row">
		<!-- 功能菜单 -->
		<jsp:include page="/mng/menu.jsp"/>
		<!-- /功能菜单 -->
		
		<!-- 主界面 -->
		<div id="main" class="main col-md-9">
			<!-- 路径导航 -->
			<ol class="breadcrumb" style="border-radius: 0;background: #fff;">
			  <li><a href="${ctx}/mng/main.jsp">首页</a></li>
			  <li><a href="#">商品管理</a></li>
			  <li class="active">新增商品</li>
			</ol>
			<!-- /路径导航 -->
			
			<!-- 表单 -->
			<div class="row">
			<form action="${ctx}/mng/prod/add.jhtml" method="post" class="form-horizontal" role="from" id="from">
				<div class="form-group">
					<label class="col-md-2 control-label">所属分类</label>
					<div class="col-md-3">
						<select class="form-control input-sm" name="cate_id">
						<c:forEach items="${cates}" var="cate">
							<option value="${cate.id}">${cate.name}</option>
						</c:forEach>
						</select>
		   		    </div>
				</div>
				<div  class="form-group">
					<label class="col-md-2 control-label">商品名称</label>
					<div class="col-md-3">
						<input type="text" class="form-control" name="name" id="name">
					</div>
					<label class="col-md-2 control-label">口味</label>
					<div class="col-md-3">
						<input type="text" class="form-control" name="model" id="model">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">成本单价</label>
					<div class="col-md-3">
						<input type="text" class="form-control" name="sale_price" id="sale_price">
					</div>
					<label class="col-md-2 control-label">商品单位</label>
					<div class="col-md-3">
						<input type="text" class="form-control" name="unit" id="unit">
		   		    </div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">保质期</label>
					<div class="col-md-3">
					<label><input type="number"  name="expireTime" id="expireTime" style="width:70px;height:40">&nbsp;&nbsp;&nbsp;天</label>
					</div>
					
								
							
					<label class="col-md-2 control-label">安全存量</label>
					<div class="col-md-3">
						<input type="number" class="form-control" name="security_num" id="security_num">
		   		    </div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">描述</label>
					<div class="col-md-3">
						<input type="text" class="form-control" name="summary">
					</div>
				</div>
				<div class="form-group" style="display:none;">
					<label class="col-md-2 control-label">数量</label>
					<div class="col-md-3">
						<input type="number" class="form-control" name="num" value="0"> 
					</div>
				</div>
				<div class="form-group">
					<div class="col-md-2 col-md-offset-3">
						<input type="button"  onclick="tijiao()"  class="form-control btn-primary" value="提交"></input>
					</div>
					<div class="col-md-2 col-md-offset-1">
						<button type="reset" class="form-control btn-warning">重置</button>
					</div>
				</div>
			</form>
			</div>
			<!-- /表单 -->
			
		</div>
		<!-- /主界面 -->
	  </div>
	</div>
<script src="${ctx}/js/jquery-1.11.1.min.js"></script>
<script src="${ctx}/bootstrap3/js/bootstrap.min.js"></script>
<script src="${ctx}/js/my.js"></script>
<script>
function tijiao(){
    	   
			var name= $("#name").val();  
			var model= $("#model").val(); 
			var sale_price= $("#sale_price").val(); 
			var unit= $("#unit").val(); 
			var expireTime= $("#expireTime").val(); 
			var security_num= $("#security_num").val();
			if(name.length==0||name==null){  
			     alert("商品名称不能为空");
			     return false;
			} 
			if(model.length==0||model==null){  
			     alert("口味不能为空");
			     return false;
			} 
			if(sale_price.length==0||sale_price==null){  
			     alert("成本单价不能为空");
			     return false;
			} 
			if(unit.length==0||unit==null){  
				
			     alert("商品单位不能为空");
			     return false;
			}
			if(expireTime.length==0||expireTime==null){  
			     alert("保质期不能为空");
			     return false;
			}
			if(expireTime<=0){  
			     alert("保质期必须为正数！");
			     return false;
			}
			if(security_num.length==0||security_num==null){  
			     alert("安全库存数量不能为空");
			     return false;
			}
			if(security_num<=0){  
			     alert("安全库存必须为正数！");
			     return false;
			} 
			$("#from").submit();
			
		}
	</script>
</body>
</html>